package com.zallds.controller;

import com.zallds.model.MysqlProps;
import com.zallds.model.PageDataResult;
import com.zallds.model.Source;
import com.zallds.utils.ReadFileUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by liujian on 2019/12/15.
 */
@Controller
@RequestMapping("/source")
public class SourceController {
    @Resource
    private MysqlProps mysqlProps;

    @RequestMapping("/add")
    public String add() {
        return "add";
    }



    @RequestMapping("/get")
    @ResponseBody
    public PageDataResult getSourceList() {
        PageDataResult pageDataResult = new PageDataResult();
        List<Source> list = ReadFileUtil.readFileByLine(mysqlProps.getMysqlSourceFile());
        pageDataResult.setList(list);
        pageDataResult.setTotals(list.size());
        return pageDataResult;
    }

}
